<template>
<<<<<<< HEAD
    <div class="standardList">
        <van-search
            @search='getDataInfo'
            v-model="searchvalue"
            shape="round"
            background="#1989fa"
            placeholder="请输入搜索关键词"
        />
        <van-pull-refresh v-model="refreshing" @refresh="onRefresh" style="margin-bottom:50px">
        <van-list
            v-model="loading"
            :finished="finished"
            finished-text="没有更多了"
            @load="onLoad"
        >
            <van-swipe-cell v-for="item in list" :key="item.fid" :title="item" style="text-align:left">
                <van-panel  class='secCard'>
                <div slot="header">
                    <div class='soltHeader van-hairline--bottom'>
                        <div style="line-height:48px;margin-left:4px">检验项目名称：222222</div>
                        <van-switch style="margin-top:6px" v-model="checked" />
                    </div>
                </div>
                <div >
                    <div class='listLiSec'>
                        检验方法名称：2222222
                    </div>
                 
                </div>
                <div slot="footer">
                    <div class='listBtns'>
                        <van-icon style="margin-right:4px" name="edit" color="#ff976a"  size='24' @click="toEditSecStandard(item)"/>
                        <van-icon style="margin-right:4px" name="eye-o" color="#1989fa" @click="toDetail(item)" size='24'/>
                        <van-icon style="margin-right:4px" name="delete" @click="delData(item)" color="#ee0a24" size='24'/>
                    </div>
                </div>
                </van-panel>
              
            </van-swipe-cell>
        </van-list>
        </van-pull-refresh>
        <div class='listBottomBtn' @click="toAddSecStandard">前往新增</div>
    </div>
</template>

<script>
import { 
    Button
    ,NavBar
    ,Icon
    ,PullRefresh 
    ,Toast
    ,List
    ,SwipeCell
    ,Collapse
    , CollapseItem
    ,Divider
    ,Panel
    ,DropdownMenu
    , DropdownItem
    ,Search
    ,Dialog
    ,Switch
    } from 'vant';
import {
    search
} from '@/api/standeadSecList'
export default {
    name: 'standeadSecList',
    components: {
        [Switch.name]:Switch,
        [NavBar.name]:NavBar,
        [Button.name]:Button,
        [Icon.name]:Icon,
        [PullRefresh.name]:PullRefresh,
        [List.name]:List,
        [SwipeCell.name]:SwipeCell,
        [Collapse.name]:Collapse,
        [CollapseItem.name]:CollapseItem,
        [Divider.name]:Divider,
        [Panel.name]:Panel,
        [DropdownMenu.name]:DropdownMenu,
        [DropdownItem.name]:DropdownItem,
        [Search.name]:Search,
        [Dialog.name]:Dialog,
    },
    data () {
        return {
            searchvalue:'',
            list: [],
            loading: false,
            finished: false,
            refreshing: false,
            totalCount:0,
            pagenumber:1,
            isLoading:false,
            finished:false,
            fstandardid:'',
            checked:true
        }
    },
    created(){
        this.fstandardid = this.$route.query.fid
    },
    methods:{
        toDetail(item){
            this.$router.push({path:"/standardDetail"});
        },
        getDataInfo(){
            search({
                fmoduleid:'base_checkstandarddtlv2',
                fstandardid:this.fstandardid,
                pagenumber:this.pagenumber,
                pagesize:10,
                searchvalue:this.searchvalue,
            }).then(res=>{
                this.totalCount = res.pageResult.totalCount
                this.list = res.pageResult.results
                this.pagenumber = res.pageResult.pageNo
                this.loading = false;
                if (this.list.length >= res.pageResult.totalCount) {
                    this.finished = true;
                }
            })
        },
        onRefresh() {
            // 清空列表数据
            this.finished = false;

            // 重新加载数据
            // 将 loading 设置为 true，表示处于加载状态
            this.loading = true;
            this.onLoad();
        },
        onLoad() {
                setTimeout(() => {
        for (let i = 0; i < 10; i++) {
          this.list.push(this.list.length + 1);
        }

        // 加载状态结束
        this.loading = false;

        // 数据全部加载完成
        if (this.list.length >= 40) {
          this.finished = true;
        }
      }, 1000);
      return
          if (this.isLoading) {
                this.list = [];
                this.isLoading = false;
            }
            search({
                fmoduleid:'base_checkstandarddtlv2',
                fstandardid:this.fstandardid,
                pagenumber:this.pagenumber,
                pagesize:10,
                searchvalue:this.searchvalue,
            }).then(res=>{
                console.log(res)
                this.totalCount = res.pageResult.totalCount
                res.pageResult.results.forEach(element => {
                    this.list.push(element);
                });
                console.log(this.list)
                this.pagenumber = res.pageResult.pageNo
                this.loading = false;
                if (this.list.length >= res.pageResult.totalCount) {
                    this.finished = true;
                }
            })

        },
        toAddSecStandard(){
            this.$router.push({path:"/addSecStandard",query:{'type':'add'}});
        },
        toEditSecStandard(item){
            this.$router.push({path:"/addSecStandard",query:{'type':'edit'}});
        },
        toStandeadSecList(item){
            this.$router.push({path:"/standeadSecList",query:{'fdetailid':item.fdetailid}});
        },
        delData(item){
            Dialog.confirm({
                title: '请确认',
                message: '确定删除该数据？'
            }).then(() => {
                deletecheckwx({
                    fid:item.fid,
                    fdetailid:item.fdetailid
                }).then(res=>{
                    if(res.data.isSuccess){
                        Toast('删除成功！')
                        this.getDataInfo()
                    }
                })
            }).catch(() => {
            // on cancel
            });
        }
    }
}
=======
  <div class="standardList">
    <van-search
      @search="getDataInfo"
      v-model="searchvalue"
      shape="round"
      background="#1989fa"
      placeholder="请输入搜索关键词"
    />
    <van-pull-refresh v-model="refreshing" @refresh="onRefresh" style="margin-bottom:50px">
      <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
        <van-swipe-cell
          v-for="item in list"
          :key="item.fdetailid"
          :title="item"
          style="text-align:left"
        >
          <van-panel class="secCard">
            <div slot="header">
              <div class="soltHeader van-hairline--bottom">
                <div style="line-height:48px;margin-left:4px">检验项目名称：{{item.fcheckitemname}}</div>
                <van-switch
                  style="margin-top:6px"
                  v-model="item.fstate=='1'"
                  @change="switchChange(item)"
                />
              </div>
            </div>
            <div>
              <div class="listLiSec">检验方法名称：{{item.fmethodname}}</div>
            </div>
            <div slot="footer">
              <div class="listBtns">
                <van-icon
                  style="margin-right:4px"
                  name="edit"
                  color="#ff976a"
                  size="24"
                  @click="toEditSecStandard(item)"
                />
                <van-icon
                  style="margin-right:4px"
                  name="eye-o"
                  color="#1989fa"
                  @click="toDetail(item)"
                  size="24"
                />
                <van-icon
                  style="margin-right:4px"
                  name="delete"
                  @click="delData(item)"
                  color="#ee0a24"
                  size="24"
                />
              </div>
            </div>
          </van-panel>
        </van-swipe-cell>
      </van-list>
    </van-pull-refresh>
    <div class="listBottomBtn" @click="toAddSecStandard">前往新增</div>
  </div>
</template>

<script>
import {
  Button,
  NavBar,
  Icon,
  PullRefresh,
  Toast,
  List,
  SwipeCell,
  Collapse,
  CollapseItem,
  Divider,
  Panel,
  DropdownMenu,
  DropdownItem,
  Search,
  Dialog,
  Switch
} from "vant";
import {
  search,
  enable,
  base_checkstandard_dtl_delete
} from "@/api/standeadSecList";
export default {
  name: "standeadSecList",
  components: {
    [Switch.name]: Switch,
    [NavBar.name]: NavBar,
    [Button.name]: Button,
    [Icon.name]: Icon,
    [PullRefresh.name]: PullRefresh,
    [List.name]: List,
    [SwipeCell.name]: SwipeCell,
    [Collapse.name]: Collapse,
    [CollapseItem.name]: CollapseItem,
    [Divider.name]: Divider,
    [Panel.name]: Panel,
    [DropdownMenu.name]: DropdownMenu,
    [DropdownItem.name]: DropdownItem,
    [Search.name]: Search,
    [Dialog.name]: Dialog
  },
  data() {
    return {
      propsfid1: "",
      searchvalue: "",
      list: [],
      loading: false,
      finished: false,
      refreshing: false,
      totalCount: 0,
      pagenumber: 1,
      isLoading: false,
      finished: false,
      fstandardid: "",
      checked: true
    };
  },
  created() {
    this.propsfid1 = this.$route.query.propsfid1;
    //this.fstandardid = this.$route.query.fid;
    this.fstandardid = "92";
  },
  methods: {
    switchChange(item) {
      if (item.fstate == 0) {
        item.fstate = 1;
        enable({
          fmoduleid: "base_checkstandarddtlv2",
          rows: item.fdetailid,
          fstate: 1
        }).then(res => {
          this.getDataInfo();
        });
      } else if (item.fstate == 1) {
        item.fstate = 0;
        enable({
          fmoduleid: "base_checkstandarddtlv2",
          rows: item.fdetailid,
          fstate: 0
        }).then(res => {
          this.getDataInfo();
        });
      }
    },
    toDetail(item) {
      console.log(item.fcheckitemid);
      this.$router.push({
        path: "/standardDetail",
        query: { propsfid2: item.fcheckitemid }
      });
    },
    getDataInfo() {
      search({
        fmoduleid: "base_checkstandarddtlv2",
        fstandardid: this.fstandardid,
        pagenumber: this.pagenumber,
        pagesize: 10,
        searchvalue: this.searchvalue
      }).then(res => {
        this.totalCount = res.total;
        this.list = res.rows;
        this.pagenumber = res.sysparams.pageNo;
        this.loading = false;
        if (this.list.length >= res.total) {
          this.finished = true;
        }
      });
    },
    onRefresh() {
      // 清空列表数据
      this.finished = false;
      // 重新加载数据
      // 将 loading 设置为 true，表示处于加载状态
      this.loading = true;
      this.onLoad();
    },
    onLoad() {
      if (this.isLoading) {
        this.list = [];
        this.isLoading = false;
      }
      search({
        fmoduleid: "base_checkstandarddtlv2",
        fstandardid: this.fstandardid,
        pagenumber: this.pagenumber,
        pagesize: 10,
        searchvalue: this.searchvalue
      }).then(res => {
        this.totalCount = res.total;
        res.rows.forEach(element => {
          this.list.push(element);
        });
        this.pagenumber = res.sysparams.pageNo;
        this.loading = false;
        if (this.list.length >= res.total) {
          this.finished = true;
        }
      });
    },
    toAddSecStandard() {
      this.$router.push({
        path: "/addSecStandard",
        query: { type: "add", propsfid1: this.propsfid1 }
      });
    },
    toEditSecStandard(item) {
      this.$router.push({
        path: "/addSecStandard",
        query: {
          type: "edit",
          propsfid2: item.fdetailid,
          propsfid1: this.propsfid1
        }
      });
    },
    toStandeadSecList(item) {
      this.$router.push({
        path: "/standeadSecList"
      });
    },
    delData(item) {
      Dialog.confirm({
        title: "请确认",
        message: "确定删除该数据？"
      })
        .then(() => {
          base_checkstandard_dtl_delete({
            fmoduleid: "base_checkstandarddtlv2",
            rows: item.fdetailid
          }).then(res => {
            if (res.isSuccess) {
              Toast.success("删除成功!");
              this.getDataInfo();
            } else {
              Toast.fail(res.message);
            }
          });
        })
        .catch(() => {
          // on cancel
        });
    }
  }
};
>>>>>>> zcm
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style>
<<<<<<< HEAD
.listBtns{
    text-align: right
}
.listConent{
    display: flex;
    width:90%;
    margin:0 auto
}
.listLiSec{
    text-align: left;
    margin-left:20px;
    line-height: 40px;
}
.listBottomBtn{
    line-height: 40px;
    width:100%;
    text-align: center;
    position: fixed;
    bottom: 0;
    left:0;
    background-color: #1989fa;
    color:white;  
}
.secCard{
    width: 94%;
    margin:0 auto;
    margin-top:16px;
    border-radius: 4px;
    border: 1px solid #ebeef5;
    background-color: #fff;
    color: #303133;
    transition: .3s;
    box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
}
.soltHeader{
    display: flex;
    line-height: 40px;
    justify-content: space-between;
=======
.listBtns {
  text-align: right;
}
.listConent {
  display: flex;
  width: 90%;
  margin: 0 auto;
}
.listLiSec {
  text-align: left;
  margin-left: 20px;
  line-height: 40px;
}
.listBottomBtn {
  line-height: 40px;
  width: 100%;
  text-align: center;
  position: fixed;
  bottom: 0;
  left: 0;
  background-color: #1989fa;
  color: white;
}
.secCard {
  width: 94%;
  margin: 0 auto;
  margin-top: 16px;
  border-radius: 4px;
  border: 1px solid #ebeef5;
  background-color: #fff;
  color: #303133;
  transition: 0.3s;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}
.soltHeader {
  display: flex;
  line-height: 40px;
  justify-content: space-between;
>>>>>>> zcm
}
</style>
